<?php
include('lib/ftree_utils.php');
require_once "HTML/Template/IT.php";

// GET HTTP "GET" VARS

if ( isset($_GET['id']) ) {
        $id = $_GET['id'];
} else {
        $id = 3054;
}
$id=preg_replace("/[^0-9]/","",$id);  //get rid of anything but numbers
if ($id < 1 || $id > pow(2,17)) {
        die("ID is out of range.");
}

// SET UP TEMPLATE

$isMobile = ChkIsMobile();
$tpl = new HTML_Template_IT("templates");
$isMobile ? $template = "person_cmnt_mtmpl.html" : $template = "person_cmnt_tmpl.html";
$status = $tpl->loadTemplatefile($template, true, true);

/* Connecting, selecting database */
$link = mysql_connect("localhost", "ftreeweb", "ftree_web")
   or die("Could not connect : " . mysql_error());
mysql_select_db("ftree") or die("Could not select database");


// GET PERSON

$query = "SELECT * FROM person WHERE `id` = $id";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
$idData = mysql_fetch_array($result, MYSQL_ASSOC);

$full = formatName($idData['first'], $idData['middle'], $idData['last'], $idData['suffix'], $idData['nick'], "fnmls");

$tpl->setVariable("PersonID", $id);
$tpl->setVariable("FullName", $full);

$tpl->show();
?>
